package com.baor.controller;

import com.baor.util.R;
import com.baor.domain.Activity;
import com.baor.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/activity")
/**
 *
 */
public class ActivityController {
    @Autowired
    private ActivityService activityService;
    @RequestMapping(value = "/began")//查询所有
    public R jinr(){
        List<Activity> b= activityService.jinru();
        return R.ok(b);
    }

    @PutMapping(value = "/cr")//插入
    public R cr(@RequestBody Activity activity){
        int x =activityService.cr(activity);
        if(x>0){
            return R.ok();
        }else {
            return R.er("添加失败");
        }
    }

    @PutMapping(value = "bj")
    public R bj(@RequestBody Activity activity){
        int y =activityService.bj(activity);
        if(y>0){
            return R.ok();
        }else {
            return R.er("编辑失败");
        }
    }

}
